package com.ys.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.ys.interceptor.LoginInterceptor;

//spring boot 2.0以上版本
@Configuration
public class MyWebMvcConfig implements WebMvcConfigurer {

	@Override
	public void addViewControllers(ViewControllerRegistry registry) {
//		registry.addViewController("/").setViewName("index");
//		registry.addViewController("/login").setViewName("login");
//		registry.addViewController("/main.html").setViewName("dashboard");
	}

	// 注册拦截器
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry
			.addInterceptor(new LoginInterceptor())
			.addPathPatterns("/api/inter/**")
			.excludePathPatterns("/login", "/index");
	}
}
